/**
 * 页面初始化时mask(dwr方法实现),使用此方法需引入drift.css，在页面加入<div id="fade" class="black_overlay"></div>
 */
function initMask(){
    useLoadingMessage("");
}

function useLoadingMessage(message){
    var loadingMessage;
    if (message) 
        loadingMessage = message;
    else 
        loadingMessage = "Loading";
    
    dwr.engine.setPreHook(function(){
        var disabledZone = $('disabledZone');
        if (!disabledZone) {
            disabledZone = document.createElement('div');
            disabledZone.setAttribute('id', 'disabledZone');
            disabledZone.style.position = "absolute";
            disabledZone.style.zIndex = "100";
            disabledZone.style.left = "0px";
            disabledZone.style.top = "0px";
            disabledZone.style.width = "100%";
            disabledZone.style.height = "100%";
            document.body.appendChild(disabledZone);
            var messageZone = document.createElement('div');
            messageZone.setAttribute('id', 'messageZone');
            messageZone.style.position = "absolute";
            messageZone.style.top = "0px";
            messageZone.style.right = "0px";
            messageZone.style.background = "red";
            messageZone.style.color = "white";
            messageZone.style.fontFamily = "Arial,Helvetica,sans-serif";
            messageZone.style.padding = "4px";
            disabledZone.appendChild(messageZone);
            var text = document.createTextNode(loadingMessage);
            messageZone.appendChild(text);
        }
        else {
            $('messageZone').innerHTML = loadingMessage;
            disabledZone.style.visibility = 'visible';
            $('fade').style.display = 'block';
        }
    });
    
    dwr.engine.setPostHook(function(){
        $('disabledZone').style.visibility = 'hidden';
        $('fade').style.display = 'none';
    });
}
